package com.gvu;

import java.util.ArrayList;
import java.util.Scanner;


class FinancialRecord {
    String date;
    double amount;
    String category;
    String note;

    public FinancialRecord(String date, double amount, String category, String note) {
        this.date = date;
        this.amount = amount;
        this.category = category;
        this.note = note;
    }

    @Override
    public String toString() {
        return "Date: " + date + ", Amount: " + amount + ", Category: " + category + ", Note: " + note;
    }
}

public class code1 {
    private static ArrayList<FinancialRecord> incomeRecords = new ArrayList<>();
    private static ArrayList<FinancialRecord> expenseRecords = new ArrayList<>();

    public static void recordIncome(String date, double amount, String category, String note) {
        if (amount > 0) {
            incomeRecords.add(new FinancialRecord(date, amount, category, note));
            System.out.println("Income recorded successfully.");
        } else {
            System.out.println("Income amount must be positive.");
        }
    }

    public static void recordExpense(String date, double amount, String category, String note) {
        if (amount > 0) {
            expenseRecords.add(new FinancialRecord(date, amount, category, note));
            System.out.println("Expense recorded successfully.");
        } else {
            System.out.println("Expense amount must be positive.");
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("Choose an option: 1. Record Income  2. Record Expense  3. Exit");
            int choice = scanner.nextInt();
            scanner.nextLine();  // Consume  some newline

            if (choice == 1 || choice == 2) {
                System.out.print("Enter date (YYYY-MM-DD): ");
                String date = scanner.nextLine();

                System.out.print("Enter amount: ");
                double amount = scanner.nextDouble();
                scanner.nextLine();  // Consume newline

                System.out.print("Enter category: ");
                String category = scanner.nextLine();

                System.out.print("Enter note: ");
                String note = scanner.nextLine();

                if (choice == 1) {
                    recordIncome(date, amount, category, note);
                } else if (choice == 2) {
                    recordExpense(date, amount, category, note);
                }
            } else if (choice == 3) {
                break;
            } else {
                System.out.println("Invalid choice. Please try again.");
            }
        }

        scanner.close();
    }
}
